<?php
/**
 * @author jonathan <jo.link.noir@gmail.com>
 * @version 1.0: jo_link_noir
 * @date 05-06-2010
 */
class U1_Resource_DAO extends SW_Resource_DAO
{
	static private $factory = null;


	/**
	 * @return #field
	 */
	static public function getFactory()
	{
		return (self::$factory)
			? self::$factory
			: self::$factory = new self('resource', 'ref_building', 'ref_planet');
	}

	/**
	 * @param int $id_structure
	 * @param int $group
	 * @param int $quantity
	 * @param int $time_end
	 * @param int $id_planet
	 * @return SW_Resource_Element
	 */
	protected function newElement($id_structure, $group, $quantity, $time_end, $id_planet)
	{
		return new U1_Resource_Element($id_structure, $group, $quantity, $time_end);
	}

	/**
	 * Sélectionne les ressources de toutes les planètes d'un joueur
	 * @param int $id_user
	 * @param string $tablePlanet = null : ignoré
	 * @param string $ref_user = null : ignoré
	 * @return array : {id_planet => {id => U1_Resource_Element, ...}, ...}
	 */
	public function selectAll($id_user, $tablePlanet = null, $ref_user = null)
	{
		return parent::selectAll($id_user, 'planet', 'ref_user');
	}
}